package spring.data.jpa.config;

import java.util.Collection;
import java.util.Collections;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension;
import org.springframework.data.repository.config.DefaultRepositoryConfiguration;
import org.springframework.data.repository.config.RepositoryConfiguration;
import org.springframework.data.repository.config.RepositoryConfigurationSource;

import spring.data.jpa.repository.CommonJpaRepository;
import spring.data.jpa.repository.factory.SimpleJpaRepositoryFactoryBean;

public class SimpleJpaRepositoryConfigExtension extends JpaRepositoryConfigExtension {

    @Override
    protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> getRepositoryConfiguration(
            BeanDefinition definition, T configSource) {
        return new DefaultRepositoryConfiguration<T>(configSource, definition, this);
    }

    /* 
     * (non-Javadoc)
     * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getIdentifyingTypes()
     */
    @Override
    protected Collection<Class<?>> getIdentifyingTypes() {
        return Collections.<Class<?>> singleton(CommonJpaRepository.class);
    }


    @Override
    public String getRepositoryFactoryBeanClassName() {
        return SimpleJpaRepositoryFactoryBean.class.getName();
    }
    
}
